package com.xzy.shop.dao.impl;

import com.xzy.shop.dao.PhotoDao;
import com.xzy.shop.domain.Photo;
import com.xzy.shop.util.JDBCUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

public class PhotoDaoImpl implements PhotoDao {
    JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
    @Override
    public List<Photo> findByGid(String gid) {
        String sql = "select * from good_img where gid = ? and imgtype = ?";
        return template.query(sql, new BeanPropertyRowMapper<Photo>(Photo.class), gid, 1);
    }

    @Override
    public List<Photo> findinfoByGid(String gid) {
        String sql = "select * from good_img where gid = ? and imgtype = ?";
        return template.query(sql, new BeanPropertyRowMapper<Photo>(Photo.class), gid, 2);
    }
}
